import { defineStore } from 'pinia'
import { reqScrennData } from '@/api/screen'

const useScreenStore = defineStore('Screen', {
  //小仓库存储数据地方
  state: () => {
    return {
      maleRatio: 0,
      femaleRatio: 0,
      totalCount: 0,
      subjectPie: [],
      courseTitleViewCountMap: {
        yData: [],
        xData: [],
      },
      sectionDateCountMap: {
        yData: [],
        xData: [],
      },
      parentSubjectCountMap: {
        yData: [],
        xData: [],
      },
    }
  },
  //异步|逻辑的地方
  actions: {
    async getScreenData() {
      const { data } = await reqScrennData()
      Object.assign(this.$state, data)
      console.log(this.$state, 'pinia')
    },
  },
  getters: {},
})
export default useScreenStore
